#!/bin/bash
source /etc/profile
. $BEETLE_SHELL_PATH/error.sh

projectName=$1

if [ ! ${projectName} ]
then
    error_exit "参数存在空值projectName"
fi

# 分支名
branch=$2

codePath=/usr/local/beetle/code/${projectName}
workPath=/usr/local/nginx
configPath=/usr/local/beetle/config/${projectName}
bakPath=/usr/beetle/appbak/${projectName}
bakName=${projectName}

bash $BEETLE_SHELL_PATH/git_checkout.sh ${codePath} ${branch} || error_exit

bash $BEETLE_SHELL_PATH/bak.sh ${workPath} ${projectName} ${bakPath} ${bakName} || error_exit

cd ${codePath} || error_exit

cp -Rf `ls |grep -v config.js` ${workPath}/${projectName}/ || error_exit

cp ${configPath}/* ${workPath}/${projectName}/ || error_exit
